#include <iostream>
#include <queue>
#include <cstring>
using namespace std;
const int N = 32;
const int M = 32;
char maze[N][M];
int dis[N][M];
typedef pair<int, int> Pos;
queue<Pos> q;
int dx[4] = { 0,0,1,-1 };
int dy[4] = { 1,-1,0,0 };
int main()
{
    memset(dis, -1, sizeof(dis));
    int n, m;
    int count = 0;
    cin >> n >> m;
    int ans = INT32_MAX;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cin >> maze[i][j];
            if (maze[i][j] == 'k')
            {
                q.push({ i,j });
                dis[i][j] = 0;
            }
        }
    }
    while (!q.empty())
    {
        int se = q.size();

        while (se--)
        {
            auto& [x, y] = q.front();
            q.pop();
            for (int i = 0; i < 4; i++)
            {
                int n_x = x + dx[i];
                int n_y = y + dy[i];


                if (n_x >= 0
                    && n_x < n
                    && n_y >= 0
                    && n_y < m
                    && maze[n_x][n_y] != '*'
                    && dis[n_x][n_y] == -1)
                {

                    dis[n_x][n_y] = dis[x][y] + 1;
                    if (maze[n_x][n_y] == '.')
                        q.push({ n_x,n_y });

                }


            }
        }
    }

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            if (maze[i][j] == 'e' && dis[i][j] != -1)
            {
                ans = min(ans, dis[i][j]);
                count++;
            }

        }
    }
    if (count == 0) cout << -1 << endl;

    else cout << count << " " << ans << endl;
    return 0;
}